package com.zhongyewx.teachercert.mvp.presenter;

import com.zhongyewx.teachercert.base.ZYBasePresenter;
import com.zhongyewx.teachercert.framework.okhttp.ZYOnHttpCallBack;
import com.zhongyewx.teachercert.mvp.contract.ZYHomeFragContact;
import com.zhongyewx.teachercert.mvp.model.ZYHomeFragModel;

public class ZYHomeFragPresenter extends ZYBasePresenter<ZYHomeFragContact.IHomeFragView> implements ZYHomeFragContact.IHomeFragPreseter {

    private ZYHomeFragModel model;

    public ZYHomeFragPresenter() {
        model = new ZYHomeFragModel();
    }

    @Override
    public void getHomeData() {
        checkViewAttach();
        mRootView.showLoading();
        model.getHomeData(new ZYOnHttpCallBack<String>() {
            @Override
            public void onSuccessful(String s) {
                if (!isOnResume()){
                    return;
                }
                mRootView.showMsg("请求成功了");
                mRootView.dismissLoading();
            }

            @Override
            public void onFaild(String errorMsg) {
                if (!isOnResume()){
                    return;
                }
                mRootView.showMsg("请求失败了");
                mRootView.dismissLoading();

            }
        });

    }
}
